<template>
  <div>
    <div id="numTread"></div>
    <!-- <div class="footer">
        <div class="ratio">
          <div class="img_box"></div>
        </div>
        <div class="count">
          <div class="count_text">
            <div>未转化商机</div>
            <div style="font-size: 20px; font-weight: bold; color: #ffffff">
              18
              <span style="font-size: 16px; color: rgba(255, 255, 255, 0.6);margin-left: 20px;"
                >个</span
              >
            </div>
          </div>
          <div class="count_img"></div>
  
          <div class="count_text">
            <div>已转化商机</div>
            <div style="font-size: 20px; font-weight: bold; color: #ffffff">
              18
              <span style="font-size: 16px; color: rgba(255, 255, 255, 0.6);margin-left: 20px;"
                >个</span
              >
            </div>
          </div>      </div>
      </div> -->
  </div>
</template>

<script setup>
import * as echarts from "echarts";
import { onMounted } from "vue";
const props = defineProps({
  id: {
    type: String,
    default: "",
  },
  data: {
    type: Array,
    default: () => {},
  },
});

onMounted(() => {
  var app = {};

  var chartDom = document.getElementById("numTread");
  var myChart = echarts.init(chartDom);
  var option;

  option = {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },
    textStyle: {
      color: "rgba(255, 255, 255, 0.6)",
      fontFamily: "Source Han Sans",
      fontSize: "18px",
      fontWeight: "normal",
    },

    xAxis: [
      {
        type: "category",
        data: [
          "1月",
          "2月",
          "3月",
          "4月",
          "5月",
          "6月",
          "7月",
          "8月",
          "9月",
          "10月",
          "11月",
          "12月",
        ],
        axisLabel: {
          //interval设置成 0 强制显示所有标签
          interval: 0,
        },
      },
    ],
    yAxis: [
      {
        type: "value",
        splitLine: {
          //网格线
          show: false,
        },
      },
    ],

    legend: {
      right: "5%",

      textStyle: {
        color: "rgba(255, 255, 255)",
      },
    },
    grid: {
      top: "10%",
      left: "1%",
      right: "0",
      bottom: "0",
      containLabel: true,
    },
    series: [
      {
        name: "线索",
        type: "bar",
        emphasis: {
          focus: "series",
        },
        data: props.data.sx,
        itemStyle: {
          // 使用方法一的写法
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: "rgba(47, 194, 217, 1)" },

            { offset: 1, color: "rgba(14, 123, 200, 1)" },
          ]),
        },
      },
      {
        name: "双落地",
        type: "bar",
        stack: "Ad",
        emphasis: {
          focus: "series",
        },

        data: props.data.sld,
        itemStyle: {
          // 使用方法一的写法
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: "#BBA96E" },

            { offset: 1, color: "#977B2F " },
          ]),
        },
      },
    ],
  };

  // option = {
  //   tooltip: {
  //     trigger: "axis",
  //     axisPointer: {
  //       type: "shadow",
  //     },
  //   },
  //   textStyle: {
  //     color: "rgba(255, 255, 255, 0.6)",
  //     fontFamily: "Source Han Sans",
  //     fontSize: "14px",
  //     fontWeight: "normal",
  //     lineHeight: "19.6px",
  //   },
  //   legend: {
  //     data: ["Forest", "Steppe"],
  //   },

  //   xAxis: [
  //     {
  //       type: "category",
  //       axisTick: { show: false },
  //       data: ["2012", "2013", "2014", "2015", "2016"],
  //     },
  //   ],
  //   yAxis: [
  //     {
  //       type: "value",
  //       splitLine: {
  //         //网格线
  //         show: false,
  //       },
  //     },
  //   ],
  //   series: [
  //     {
  //       name: "Forest",
  //       type: "bar",
  //       barGap: 0,
  //       label: '456',
  //       emphasis: {
  //         focus: "series",
  //       },
  //       data: [320, 332],
  //       itemStyle: {
  //         // 使用方法一的写法
  //         color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  //           { offset: 0, color: "#6ED29B" },

  //           { offset: 1, color: "#0E7BC8" },
  //         ]),
  //       },
  //     },
  //     {
  //       name: "Steppe",
  //       type: "bar",
  //       label: '123',
  //       emphasis: {
  //         focus: "series",
  //       },
  //       data: [220, 182, 191, 234, 290],
  //       itemStyle: {
  //         // 使用方法一的写法
  //         color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  //           { offset: 0, color: "#BBA96E" },

  //           { offset: 1, color: "#977B2F " },
  //         ]),
  //       },
  //     },
  //   ],
  // };

  option && myChart.setOption(option);
});
</script>

<style scoped>
#numTread {
  width: 100%;
  height: 450px;
}

.footer {
  width: 100%;
  height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ratio {
  position: relative;
  width: 373px;
  height: 52px;
  opacity: 1;
}

.count {
  position: relative;

  width: 1059px;
  height: 52px;
  opacity: 1;
  background: linear-gradient(
    90deg,
    rgba(13, 31, 38, 0.4) 3%,
    rgba(23, 51, 62, 0.4) 47%,
    rgba(13, 31, 38, 0.4) 99%
  );

  box-shadow: inset 0px 0px 4px 0px #5493d8;
  display: flex;
  justify-content: center;
  align-items: center;
}

.count_text {
  width: 30%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  font-style: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.count_img {
  margin-top: -10px;
  width: 66px;
  height: 66px;
  background: url("../../img/mark.png") no-repeat;
  background-size: cover;
}

.img_box {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: url("../../img/ratio.png") no-repeat;
  background-size: cover;
}
</style>
